package com.guigu.pd.aggregation.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.guigu.pd.aggregation.entity.FleetEntity;
import com.guigu.pd.aggregation.service.FleetService;
import com.guigu.common.utils.PageUtils;
import com.guigu.common.utils.R;



/**
 * 车队表
 *
 * @author deyran
 * @email deyran@gmail.com
 * @date 2022-07-19 18:28:30
 */
@RestController
@RequestMapping("aggregation/fleet")
public class FleetController {
    @Autowired
    private FleetService fleetService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("aggregation:fleet:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = fleetService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("aggregation:fleet:info")
    public R info(@PathVariable("id") String id){
		FleetEntity fleet = fleetService.getById(id);

        return R.ok().put("fleet", fleet);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("aggregation:fleet:save")
    public R save(@RequestBody FleetEntity fleet){
		fleetService.save(fleet);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("aggregation:fleet:update")
    public R update(@RequestBody FleetEntity fleet){
		fleetService.updateById(fleet);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("aggregation:fleet:delete")
    public R delete(@RequestBody String[] ids){
		fleetService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
